package com.isman.domain;


import java.io.Serializable;

import javax.persistence.*;

import com.google.appengine.repackaged.org.codehaus.jackson.annotate.JsonManagedReference;
import com.google.appengine.repackaged.org.codehaus.jackson.map.annotate.JsonSerialize;

import org.hibernate.internal.util.Cloneable;

@Entity
@Table(name="person") 
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class Person extends Cloneable implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	private int id;

	@Column(nullable=false, length=32)
	private String city;

	@Column(nullable=false, length=24)
	private String firstName;

	@Column(nullable=false, length=24)
	private String lastName;

	@Column(nullable=false, length=32)
	private String phoneNumber;

	@Column(nullable=false, length=512)
	private String street;

	@Column(nullable=false, length=32)
	private String zipCode;
	
	@JsonManagedReference
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="department_id")
	private Department department = new Department();

	public Person() {
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}
	
	@Override
	public String toString() {
		return "Person [id=" + id + ", city=" + city + ", firstName="
				+ firstName + ", lastName=" + lastName + ", phoneNumber="
				+ phoneNumber + ", street=" + street + ", zipCode=" + zipCode
				+ ", department=" + department + "]";
	}

}